# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=gtest
pkgver=1.12.1
pkgrel=0
pkgdesc="Google Test - C++ testing utility based on the xUnit framework (like JUnit)"
url="https://github.com/google/googletest"
arch="all"
license="BSD-3-Clause"
depends_dev="$pkgname=$pkgver-r$pkgrel gmock=$pkgver-r$pkgrel"
makedepends="$depends_dev cmake python3-dev samurai"
subpackages="$pkgname-dev gmock"
source="$pkgname-$pkgver.tar.gz::https://github.com/google/googletest/archive/refs/tags/release-$pkgver.tar.gz"
builddir="$srcdir/googletest-release-$pkgver"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=ON \
		-DPYTHON_EXECUTABLE=python3 \
		-Dgtest_build_tests=ON \
		-DBUILD_GMOCK=ON
	cmake --build build
}

check() {
	# fails of x86
	ctest --test-dir build -E "googletest-port-test"
}

package() {
	DESTDIR="$pkgdir" cmake --build build --target install
	find "$pkgdir" -name '*.pump' -print -delete
}

gmock() {
	pkgdesc="Google Mock - A library for writing and using C++ mock classes"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libgmock*.so* "$subpkgdir"/usr/lib/
}

sha512sums="
a9104dc6c53747e36e7dd7bb93dfce51a558bd31b487a9ef08def095518e1296da140e0db263e0644d9055dbd903c0cb69380cb2322941dbfb04780ef247df9c  gtest-1.12.1.tar.gz
"
